<?
/**
* Copyright (c) 2002-2007 BioWare Corp.
* http://www.bigdaddymonitor.org
*
* This file is part of the BigDaddy Monitoring
* program. It is free software distributed under
* the terms of the BSD License. It is ditributed
* in the hopes that it will be useful, but
* WITHOUT ANY WARRANTY; without event the implied
* warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE.
*
* The BSD License is available from:
* http://www.opensource.org/licenses/bsd-license.php
**/

$sType = $_REQUEST["type"];
$sOrder = $_REQUEST["order"];

if ($sOrder != "")
{
    $aOptions["orderby"] = $sOrder;
}


$aTypes = $RoleAdmin->GetUserRelationshipTypes();
if(strlen($sType) > 0)
{
    $aUserRelns = $RoleAdmin->GetUserRelationshipsByType($sType, $aOptions);
}

?>

<form method="get" action="<?=$_SERVER["PHP_SELF"];?>">
    <input type="hidden" name="page" value="listuserrels">
    <select name="type" size=1 id="app_select">
        <?
	foreach($aTypes as $sCurType)
	{
	    $s = "";
	    if($sType == $sCurType)
	    {
		$s = " selected";
	    }
            ?>
            <option value="<?=$sCurType?>" <?=$s?>><?=$sCurType?></option>
            <?
        }
	?>
    </select>
    <input type="submit" value="View User Relationships" name="submit" id="app_submit" style="float: none">
</form>


<p><a href="<?=$_SERVER["PHP_SELF"];?>?page=adduserrel">Add a New User Relationship</a></p>

<?
if ($sType != "")
{
    ?>

<table border="0" cellpadding="0" cellspacing="0" class="app_table">
<tr class="app_mainrow">
    <td>
	<b><a href="<?=$_SERVER["PHP_SELF"];?>?page=<?=$_GET["page"];?>&type=<?=$_GET["type"];?>&order=primaryusername">Primary Username</a></b>
    </td>
    <td>
	<b><a href="<?=$_SERVER["PHP_SELF"];?>?page=<?=$_GET["page"];?>&type=<?=$_GET["type"];?>&order=secondaryusername">Secondary Username</a></b>
    </td>
    <td>
	<b><a href="<?=$_SERVER["PHP_SELF"];?>?page=<?=$_GET["page"];?>&type=<?=$_GET["type"];?>&order=actiontype">Action Type</a></b>
    </td>
    <td>
	<b>Options</b>
    </td>
</tr>

<?
if (is_array($aUserRelns))
{
    foreach($aUserRelns as $aReln)
    {
	?>
	<tr valign="top" class="app_row">
	    <td>
		<?=$aReln["primaryUsername"];?>
	    </td>
	    <td>
		<?=$aReln["secondaryUsername"];?>
	    </td>
	    <td>
		<a href="<?=$_SERVER["PHP_SELF"];?>?page=editroleaction&ID=<?=$aReln["actionID"];?>"><?=$aReln["userAction"];?></a>
	    </td>
	    <td>
		<a href="<?=$_SERVER["PHP_SELF"];?>?page=edituserrel&ID=<?=$aReln["ID"];?>">Edit</a> |
		<a href="<?=$_SERVER["PHP_SELF"];?>?page=removeuserrel&ID=<?=$aReln["ID"];?>&type=<?=$_GET["type"];?>" onclick="javascript: return confirm('Are you sure?');">Delete</a>
	    </td>
	</tr>
	<?
	
    }
    
}

?>

</table>

<?
}
?>




